<!DOCTYPE html>
<html>
    <head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>用户管理- 添加用户</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<link rel="shortcut icon" href="../favicon.ico">
	<link href="__PUBLIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__PUBLIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
	<link href="__PUBLIC__/css/animate.css" rel="stylesheet">
	<link href="__PUBLIC__/css/style.css?v=4.1.0" rel="stylesheet">
	<link rel="stylesheet" href="__PUBLIC__/css/liandong.css"/>
	<link href="__PUBLIC__/Widget/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
	<script src="__PUBLIC__/js/plugins/layer/laydate/laydate.js"></script>
	<style>
	    .img{ width: auto !important; max-width: 128px; max-height: 128px; }
	    .img_default{ width: auto !important; max-width: 128px; max-height: 128px; }
	    .bindnum-content{ border:0; padding: 20px 15px; }
	    .bindnum-content .form-group{ overflow: hidden; }
	    .bindnum-content .form-group input[type="text"]{ margin-left:0; }
	    .bindnum-content .form-group:first-child{ margin-top: 0; }
	    .bindnum-content .form-group:last-child{ margin-bottom: 0; }
	</style>
    </head>
    <body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
	    <div class="row">
		<div class="col-sm-12">
		    <div class="ibox float-e-margins">
			<div class="ibox-title">
			    <h5>用户管理- <small><{$columnname}></small>
			    </h5>
			</div>
			<div class="ibox-content">
			    <form method="post" class="form-horizontal" onsubmit="return false">
				<if condition="$uid">
				    <div class="form-group">
					<label class="col-sm-2 control-label"><{$app_name2}>号</label>
					<div class="col-sm-10 control-label" style="text-align: left;">
					    <{$data.user_id}>
					</div>
				    </div>
				    <!--				    <div class="form-group">
									    <label class="col-sm-2 control-label">激活码</label>
									    <div class="col-sm-10 control-label" style="text-align: left;">
										<{$data.code}>
									    </div>
									</div>-->
				</if>
				<div class="form-group">
				    <label class="col-sm-2 control-label">头像</label>
				    <div class="col-sm-10">
					<div class="btn-file">
					    <button class="btn btn-primary">上传图片</button>
					    <input id="logoimg" type="file" name="logoimg">
					    <input id="logosrc" type="hidden" name="logosrc" value="<{$data.user_logo}>">
					</div>
					<div  class="product_img">
					    <if condition="$data.user_logo neq null && $data.user_logo neq ''">
						<img id="inputfile-img" alt='未找到图片' src="<{$data.user_logo}>" class="img">
						<else />
						<img id="inputfile-img" alt='未找到图片' src="__PUBLIC__/img/webuploader.png" class="img_default">
					    </if>
					</div>
				    </div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">昵称</label>
				    <div class="col-sm-10">
					<input type="text" class="form-control" value="<{$data.user_name}>" placeholder="请输入昵称" id="txtname">
				    </div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">性别</label>
				    <div class="col-sm-10">
					<select class="form-control" id="ddlsex">
					    <volist name="sexarr" id="sexarr">
						<option value="<{$sexarr.value}>" <{$sexarr.selected}>><{$sexarr.text}></option>
					    </volist>
					</select>
				    </div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">手机号码</label>
				    <div class="col-sm-10 control-label text-left" style='text-align: left;'>
					<{$data.user_phone}>
				    </div>
				</div>
				<!--				<div class="form-group">
								    <label class="col-sm-2 control-label">代理</label>
								    <div class="col-sm-10">
									<select class="form-control" id="ddlagent">
									    <volist name="agentarr" id="agentarr">
										<option value="<{$agentarr.value}>" <{$agentarr.selected}>><{$agentarr.text}></option>
									    </volist>
									</select>
								    </div>
								</div>-->
				<if condition='$login_type eq 2'>
				    <div class="form-group">
					<label class="col-sm-2 control-label">视频通话价格/分钟</label>
					<div class="col-sm-10 control-label text-left" style='text-align: left;'>
					    <{$data.user_gold}> 金币
					</div>
				    </div>
				    <div class="form-group">
					<label class="col-sm-2 control-label">余额</label>
					<div class="col-sm-10 control-label text-left" style='text-align: left;'>
					    <{$data.balance}> 金币
					</div>
				    </div>
				    <else/>
				    <div class="form-group">
					<label class="col-sm-2 control-label">视频通话价格（金币）/分钟</label>
					<div class="col-sm-10">
					    <input type="text" class="form-control int" value="<{$data.user_gold}>" placeholder="请输入没有小数位的数字" id="txtgold">
					</div>
				    </div>
				    <div class="form-group">
					<label class="col-sm-2 control-label">余额</label>
					<div class="col-sm-10">
					    <!--					    <input type="text" class="form-control int" value="<{$data.balance}>" placeholder="请输入没有小数位的数字" id="txtbalance">-->
					    <{$data.balance}> 金币
					    <if condition='$data.app_flag eq $app_code or $app_code eq ""'>&nbsp;<button class="btn btn-primary" type="button" onclick="balance_edit()">修改余额</button></if>
					    &nbsp;<button class="btn btn-primary" type="button" onclick="javascript:location.href = '__CONTROLLER__/userbalancedetail/uid/<{$data.user_uid}>'">收支明细</button>
					</div>
				    </div>
				</if>
				<if condition="$data.user_auth eq 2">
				<div class="form-group">
				    <label class="col-sm-2 control-label">认证等级</label>
				    <div class="col-sm-10 " style='text-align: left;'>
						<select name="ddvip" id="ddvip" class="form-control">
							<option value="0" >0 星级</option>
							<volist name="viparr" id="viparr" >
								<option value="<{$viparr.id}>" <{$viparr.selected}>><{$viparr.text}></option>
							</volist>
						</select>
				    </div>
				</div>
					<else />
					<input type="hidden" name="ddvip2" id="ddvip2" value="1">
				</if>
				<div class="form-group">
				    <label class="col-sm-2 control-label">出生日期</label>
				    <div class="col-sm-10">
					<input type="text" class="form-control" value="<{$data.user_birthday}>" placeholder="请输入出生日期" id="txtbirthday" readonly="readonly" onclick="laydate({istime: false, format: 'YYYY-MM-DD'})" />
				    </div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">身高</label>
				    <div class="col-sm-10">
					<input type="text" class="form-control" value="<{$data.user_height}>" placeholder="请输入身高" id="txtheight">
				    </div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">体重</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" value="<{$data.user_weight}>" placeholder="请输入体重" id="txtweight">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">形象标签</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" value="<{$data.user_tag}>" placeholder="请输入标签,格式如：青春可爱 大长腿" id="txtusertag">

						<label class="control-label"><{$data.user_tag}></label>
					</div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">个性签名</label>
				    <div class="col-sm-10">
					<input type="text" class="form-control" value="<{$data.user_describe}>" placeholder="请输入个性签名" id="txtdescribe">
				    </div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">所在地</label>
				    <div class="col-sm-10">
					<input type="text" class="form-control" value="<{$data.user_address}>" placeholder="请输入所在地" id="txtaddress">
				    </div>
				</div>
								<div class="form-group">
								    <label class="col-sm-2 control-label">是否推荐</label>
								    <div class="col-sm-10">
									<select class="form-control" id="ddlrecom">
									    <volist name="recomarr" id="recomarr">
										<option value="<{$recomarr.value}>" <{$recomarr.selected}>><{$recomarr.text}></option>
									    </volist>
									</select>
								    </div>
								</div>
								<div class="form-group">
								    <label class="col-sm-2 control-label">是否活跃</label>
								    <div class="col-sm-10">
									<select class="form-control" id="ddlactive">
									    <volist name="activearr" id="activearr">
										<option value="<{$activearr.value}>" <{$activearr.selected}>><{$activearr.text}></option>
									    </volist>
									</select>
								    </div>
								</div>
								<div class="form-group">
								    <label class="col-sm-2 control-label">是否排行</label>
								    <div class="col-sm-10">
									<select class="form-control" id="ddlhot">
									    <volist name="hotarr" id="hotarr">
										<option value="<{$hotarr.value}>" <{$hotarr.selected}>><{$hotarr.text}></option>
									    </volist>
									</select>
								    </div>
								</div>
								<div class="form-group">
								    <label class="col-sm-2 control-label">上下架</label>
								    <div class="col-sm-10">
									<select class="form-control" id="ddlflag">
									    <volist name="flagarr" id="flagarr">
										<option value="<{$flagarr.value}>" <{$flagarr.selected}>><{$flagarr.text}></option>
									    </volist>
									</select>
								    </div>
								</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">直播状态</label>
						<div class="col-sm-10">
							<select class="form-control" id="state_list">
								<volist name="state_list" id="state_list">
									<option value="<{$state_list.key}>" <{$state_list.selected}> ><{$state_list.value}></option>
								</volist>
							</select>
						</div>
					</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">状态</label>
				    <div class="col-sm-10 control-label" style="text-align: left;">
					<{$data.user_state_text}>
				    </div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">创建时间</label>
				    <div class="col-sm-10 control-label" style="text-align: left;">
					<{$ctime}>
				    </div>
				</div>
				<div class="hr-line-dashed"></div>
				<div class="form-group">
				    <div class="col-sm-4 col-sm-offset-2">
					<button class="btn btn-primary" type="button" onclick="user_add_submit(this)"><{$btnname}></button>&nbsp;&nbsp;&nbsp;
					<button class="btn btn-white" type="reset">重置</button>
				    </div>
				</div>
			    </form>
			</div>
		    </div>
		</div>
	    </div>
	</div>
	<div class="ibox-content balance-content" style="display: none;">
	    <form method="post" class="form-horizontal" onsubmit="return false">
		<div class="form-group">
		    <div class="col-sm-12">
			<input type="text" value="" class="form-control int" placeholder="请输入没有小数位的数字" id="txtbalance">
		    </div>
		</div>
		<div class="form-group">
		    <div class="col-sm-12">
			<textarea id="txtbalanceremark" class="form-control" name="content" placeholder="请输入摘要" style="height:72px;"></textarea>
		    </div>
		</div>
	    </form>
	</div>
	<!--  全局js -->
	<script src="__PUBLIC__/js/jquery.min.js?v=2.1.4"></script>
	<script src="__PUBLIC__/js/bootstrap.min.js?v=3.3.6"></script>
	<!-- 自定义js -->
	<script src="__PUBLIC__/js/content.js?v=1.0.0"></script>
	<script src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>
	<script src="__PUBLIC__/js/liandong.js"></script> 
	<script src="__PUBLIC__/js/ajaxfileupload.js"></script>
	<script src="__PUBLIC__/Widget/webuploader/0.1.5/webuploader.min.js"></script>
	<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
	<script>
		var uid = "<{$uid}>";
		var phone = "<{$phone}>";
		var balance = "<{$data.balance}>";
		var login_type = "<{$login_type}>";
		var imguploadsubmit = "<{:U('imgupload','','')}>";
		var useraddsubmit = "<{:U('useraddsubmit','','')}>";
		var userbalanceeditsubmit = "<{:U('userbalanceeditsubmit','','')}>";
		var userlist = "<{:U('userlist','','shtml')}>";
		var userdetail = "<{:U('userdetail','','')}>";
		function check_int(val) {
		    return /^[0-9]*$/.test(val);
		}
		var $logoimg = $("#logoimg");
		var $logosrc = $("#logosrc");
		var $form_group = $(".form-group:visible");
		var $txt_int = $form_group.find(".int");
		$logoimg.change("propertychange", function () {
		    ajaxFileUpload();
		});
		$txt_int.blur(function () {
		    var val = $(this).val();
		    if (val != "" && !check_int(val)) {
			layer.alert('无效的内容！\r\n', {title: '提示框', icon: 0});
			return false;
		    }
		});
		function user_add_submit(obj) {
		    var $obj = $(obj);
		    var $logosrc = $('#logosrc');
		    var $txtname = $('#txtname');
		    var $ddlsex = $('#ddlsex');
		    var $ddlagent = $('#ddlagent');
		    var $txtgold = $('#txtgold');
		    var $txtbalance = $('#txtbalance');
		    var $txtbirthday = $('#txtbirthday');
		    var $txtprofession = $('#txtprofession');
		    var $txtdescribe = $('#txtdescribe');
		    var $txtaddress = $('#txtaddress');
		    var $ddlflag = $('#ddlflag');
		    var $ddlrecom = $('#ddlrecom');
		    var $ddlactive = $('#ddlactive');
		    var $ddlhot = $('#ddlhot');
		    var $ddvip = $('#ddvip');
		    var $txtheight = $('#txtheight');
		    var $txtweight = $('#txtweight');

			var user_tag = $('#txtusertag').val();
			var state_list = $('#state_list').val();
		    var logosrc = $logosrc.val();
		    var name = $txtname.val();
		    var sex = $ddlsex.val();
		    var agent = $ddlagent.val();
		    var gold = $txtgold.val();
//		    var balance = $txtbalance.val();
		    var birthday = $txtbirthday.val();
		    var profession = $txtprofession.val();
		    var describe = $txtdescribe.val();
		    var address = $txtaddress.val();
		    var flag = $ddlflag.val();
		    var recom = $ddlrecom.val();
		    var active = $ddlactive.val();
		    var height = $txtheight.val();
		    var weight = $txtweight.val();
		    var hot = $ddlhot.val();
		    var vip = $ddvip.val();
		    var vip2 = $('#ddvip2').val();
		    if( vip2>0 ) {
                var vip = $ddvip.val();
            }
//						if (logosrc == "") {
//						    layer.alert('图片不能为空！\r\n', {title: '提示框', icon: 0});
//						    return false;
//						}
//						if (name == "") {
//						    layer.alert('名称不能为空！\r\n', {title: '提示框', icon: 0});
//						    return false;
//						}
		    if (login_type != '2') {
			if (gold == "" || !check_int(gold)) {
			    layer.alert('无效的视频通话价格！\r\n', {title: '提示框', icon: 0});
			    return false;
			}
			if (balance == "" || !check_int(balance)) {
			    layer.alert('无效的余额！\r\n', {title: '提示框', icon: 0});
			    return false;
			}
			if (balance.length > 9) {
			    layer.alert('余额不能超出 999999999 金币！\r\n', {title: '提示框', icon: 0});
			    return false;
			}
		    }
//						$obj.html(labname + '中…').removeClass('btn-primary').unbind('click').removeAttr('onclick');
		    layer.confirm('确定<{$btnname}>该用户信息吗？', function (index) {
			layer.close(index);
			//加载loading层
			var loading = layer.load(1, {
			    shade: [0.1, '#fff'] //0.1透明度的白色背景
			});
			$.post(useraddsubmit, {'uid': uid,'state_list' : state_list, 'user_tag' : user_tag,'img': logosrc, 'name': name, 'sex': sex, 'agent': agent, 'gold': gold, 'balance': balance, 'birthday': birthday, 'profession': profession, 'describe': describe, 'address': address, 'flag': flag, 'recom': recom, 'active': active, 'hot': hot, 'vip' : vip,'height':height,'weight':weight},
				function (data) {
				    if (data.ret == '1001') {
					layer.close(loading);
					layer.msg(data.code, {icon: 6, time: 1000});
					setTimeout(function () {
//									window.location.href = userlist;
					    window.location.href = userdetail + '/uid/' + uid;
					}, 1000);
				    } else {
					layer.close(loading);
					layer.msg(data.code, {icon: 5, time: 1000});
//								    $obj.html(labname).addClass('btn-primary').attr('onclick', 'user_add_submit(this)');
				    }
				}, 'json');
		    });
		}
		function ajaxFileUpload() {
		    $.ajaxFileUpload({
			url: imguploadsubmit, //你处理上传文件的服务端
			type: 'post',
			data: {phone: phone, type: 'photos'},
			secureuri: false, //与页面处理代码中file相对应的ID值
			fileElementId: 'logoimg',
			dataType: 'JSON', //返回数据类型:TEXT，XML，JSON，HTML，SCRIPT，JSONP五种
			success: function (data, status) {
			    var $inputfileimg = $("#inputfile-img");
			    var $logosrc = $("#logosrc");
			    var $logoimg = $("#logoimg");
			    data = $(data).text();
			    data = data.substring(0, data.indexOf('}') + 1);
			    data = eval("(" + data + ")");
			    if (data.ret == '1001') {
				layer.msg(data.code, {icon: 6, time: 1000});
				$inputfileimg.removeClass('img_default').addClass('img').attr('src', data.data);
				$logosrc.val(data.data);
			    } else {
				layer.msg(data.code, {icon: 5, time: 1500});
			    }
			    $logoimg.change("propertychange", function () {//再次绑定
				ajaxFileUpload();
			    });
			},
			error: function (data, status, e) {
			    alert(status);
			}
		    });
		    return false;
		}
		function balance_edit() {
		    var $content = $('.balance-content');
		    var $txtbalance = $content.find('#txtbalance');
		    var $txtbalanceremark = $content.find('#txtbalanceremark');
		    $txtbalance.val(balance).blur(function () {
			var val = $txtbalance.val();
			if (val != "" && !check_int(val)) {
			    layer.alert('无效的内容！\r\n', {title: '提示框', icon: 0});
			    return false;
			}
		    });
		    $txtbalanceremark.val('');
		    //页面层
		    layer.open({
			title: '修改余额',
			type: 1,
			skin: 'layui-layer-rim', //加上边框
			btn: ['确定', '取消']
			, yes: function (index, layero) {
			    var balance = $txtbalance.val();
			    var balanceremark = $txtbalanceremark.val();
			    if (balance == "" || !check_int(balance)) {
				layer.alert('无效的余额！\r\n', {title: '提示框', icon: 0});
				return false;
			    }
			    if (balance.length > 6) {
				layer.alert('自定义余额不能超出 999999 金币！\r\n', {title: '提示框', icon: 0});
				return false;
			    }
			    $.post(userbalanceeditsubmit, {'uid': uid, 'balance': balance, 'balanceremark': balanceremark},
				    function (data) {
					if (data.ret == '1001') {
					    layer.close(index);
					    layer.msg(data.code, {icon: 6, time: 1500});
					    setTimeout(function () {
						window.location.reload();
					    }, 1500);
					} else {
//						layer.close(index);
					    layer.msg(data.code, {icon: 5, time: 1500});
					}
				    }, 'json');
			}, cancel: function () {
			    //右上角关闭回调
			},
			area: ['320px', '278px'], //宽高
			content: $content
		    });
		}

	</script>
    </body>
</html>
